export const shop =  {
	state: {
	  shopCar: [],
	  shopInfo: {
		  name: null,
		  price: 0
	  }
	},
	getters: {
	  getShopCar: state => {return state.shopCar},
	  getShopInfo: state => {return state.shopInfo},
	  totalPrice (state) {
	  	if(state.shopCar.length > 0) {
	  		let sum = 0;
	  		state.shopCar.forEach((res)=>{
	  			sum = sum + res.price
	  		})
	  		return sum.toFixed(2)
	  	} else {
	  		return 0
	  	}
	  }
	},
	mutations: {
		mutShopCar (state,data) {
			state.shopCar.push(data)
		},
		removeShopCar(state,index) {
			state.shopCar.splice(index,1)
		},
		mutShopInfo (state,obj) {
			let {name,price} = obj
			state.shopInfo.name = name
			state.shopInfo.price = price
		}
	},
	actions: {}
}